package com.lq.demo.demo.mode.observer;

import java.util.HashSet;
import java.util.Set;

public class Transporter implements Watched {


    private Set<Watcher> set = new HashSet<>();

    @Override
    public void addWatcher(Watcher watcher) {
        set.add(watcher);
    }

    @Override
    public void romoveWatcher(Watcher watcher) {
        set.remove(watcher);
    }

    @Override
    public void notifiWatchers(Object object) {
        set.forEach(watcher -> {
            watcher.update(object);
        });
    }
    public  void  setMessage(String str){
        notifiWatchers(str);
    }
}
